package com.yael.tables;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.PersistenceManager;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.yael.utils.CacheManagerService;
import com.yael.utils.Datastore;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class NP_DN_ROUTE implements Serializable {

	@Persistent
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long routeID;
	
	@Persistent
	private Long processID; 
	
	@Persistent
	private String requestID; 
	
	@Persistent
	private Date routeDate;
	
	@Persistent 
	private String dnFrom;
	
	@Persistent 
	private String dnTo;
	
	@Persistent 
	private Long currNetworkID;
	
	@Persistent 
	private Long prevNetworkID;
	
	@Persistent 
	private String routeType;	

	@Persistent 
	private String createdBY;
	
	@Persistent
	private Date creationDate;
	
	@Persistent 
	private String lastUpdateBY;
	
	@Persistent
	private Date lastUpdateDate;
	
	@Persistent
	private String lrn;
	
	public Long getRouteID() {
		return routeID;
	}

	public void setRouteID(Long routeID) {
		this.routeID = routeID;
	}

	public Long getProcessID() {
		return processID;
	}

	public void setProcessID(Long processID) {
		this.processID = processID;
	}

	public String getRequestID() {
		return requestID;
	}

	public void setRequestID(String requestID) {
		this.requestID = requestID;
	}

	public Date getRouteDate() {
		return routeDate;
	}

	public void setRouteDate(Date routeDate) {
		this.routeDate = routeDate;
	}

	public String getDnFrom() {
		return dnFrom;
	}

	public void setDnFrom(String dnFrom) {
		this.dnFrom = dnFrom;
	}

	public String getDnTo() {
		return dnTo;
	}

	public void setDnTo(String dnTo) {
		this.dnTo = dnTo;
	}

	public Long getCurrNetworkID() {
		return currNetworkID;
	}

	public void setCurrNetworkID(Long currNetworkID) {
		this.currNetworkID = currNetworkID;
	}

	public Long getPrevNetworkID() {
		return prevNetworkID;
	}

	public void setPrevNetworkID(Long prevNetworkID) {
		this.prevNetworkID = prevNetworkID;
	}

	public String getRouteType() {
		return routeType;
	}

	public void setRouteType(String routeType) {
		this.routeType = routeType;
	}

	public String getCreatedBY() {
		return createdBY;
	}

	public void setCreatedBY(String createdBY) {
		this.createdBY = createdBY;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getLastUpdateBY() {
		return lastUpdateBY;
	}

	public void setLastUpdateBY(String lastUpdateBY) {
		this.lastUpdateBY = lastUpdateBY;
	}

	public Date getLastUpdateDate() {
		return lastUpdateDate;
	}

	public void setLastUpdateDate(Date lastUpdateDate) {
		this.lastUpdateDate = lastUpdateDate;
	}

	public String getLrn() {
		return lrn;
	}

	public void setLrn(String lrn) {
		this.lrn = lrn;
	}
	
	 public NP_DN_ROUTE store(PersistenceManager pm, CacheManagerService cm) {
		 NP_DN_ROUTE route = null;
	        try {
	        	route = pm.makePersistent(this);
	        	this.routeID = route.getRouteID();
	        	cm.setValue(Long.toString(this.routeID), this);
	        } finally {
	            pm.close();
	        }
	        return this;
	 }
	 
	 public static NP_DN_ROUTE retriveByID(PersistenceManager pm, CacheManagerService cs, String messageID){
		 Object object = null;
		 object = cs.getValue(messageID);
		 if(object!=null) {
			 object = Datastore.retriveByID(pm, NP_DN_ROUTE.class, Long.parseLong(messageID));
			 cs.setValue(messageID, object);
		 }
		 if(object!=null) return (NP_DN_ROUTE) object;
		 return null;
	 }

	
}

